package info.akabana.yui.examples.fx3.emplist.helper
{
	import info.akabana.yui.examples.fx3.empinfo.view.EmpInfoView;
	import info.akabana.yui.examples.fx3.model.EmpInfoModel;
	
	import mx.collections.ArrayCollection;
	import mx.controls.DataGrid;
	
	import org.seasar.akabana.yui.core.event.send;
	import org.seasar.akabana.yui.framework.ns.viewpart;

	use namespace viewpart;
	
	public class EmpListHelper
	{
		viewpart var empinfovw:EmpInfoView;
		viewpart var dtgrdEmpList:DataGrid;
		
		public function setEmpList(data:ArrayCollection):void {
			dtgrdEmpList.dataProvider = data;
		}
		
		public function sendModel():void {
			if (dtgrdEmpList.selectedItem is EmpInfoModel) {
				var model:EmpInfoModel = dtgrdEmpList.selectedItem as EmpInfoModel;
				send(empinfovw, "send", model);
			}
		}
		
		public function setModel(model:EmpInfoModel):void {
			dtgrdEmpList.selectedItem = model;
		}
	}
}